package com.example.user.myfirstapp.activity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import com.example.user.myfirstapp.R;
import com.example.user.myfirstapp.entity.NewsInfo;

/**
 * Created by user on 2016/6/21.
 */
public class NewsInfoActivity extends Activity implements View.OnClickListener{
    private Intent intent;
    private TextView tv_newsInfo_title,tv_newsInfo_content;
    private Button tv_newsInfo_return;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.news_info);
        tv_newsInfo_return=(Button)findViewById(R.id.tv_newsInfo_return);
        tv_newsInfo_return.setOnClickListener(this);
        tv_newsInfo_title=(TextView)findViewById(R.id.tv_newsInfo_title);
        tv_newsInfo_content=(TextView)findViewById(R.id.tv_newsInfo_content);

        intent =getIntent();
        NewsInfo news =(NewsInfo)intent.getSerializableExtra("news");
        if(news!=null){
            tv_newsInfo_title.setText(news.getNewsName());
            tv_newsInfo_content.setText(news.getNewsContent());
        }
    }

    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.tv_newsInfo_return:
                //不用new Intent，直接用finish()，这样可以保持列表页滚动位置不动
                //intent=new Intent(this, NewsActivity.class);
                //startActivity(intent);
                this.finish();
                //从左往右切换
                this.overridePendingTransition(0,R.animator.slide_right_out);
                break;

            default:
                break;
        }
    }
}
